package com.moco.launcher.listener;

import com.android.volley.NetworkError;
import com.android.volley.NoConnectionError;
import com.android.volley.Response;
import com.android.volley.ServerError;
import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;

public class CloudErrorListener implements Response.ErrorListener {

	private CloudListener mL = null;

	public CloudErrorListener(CloudListener l) {
		mL = l;
	}

	@Override
	public void onErrorResponse(VolleyError error) {
		// TODO Auto-generated method stub
		try {
			if (mL != null && error != null) {
				if (error instanceof NoConnectionError) {
					mL.onError(6000, error.toString());
				} else if (error instanceof NetworkError) {
					mL.onError(error.networkResponse.statusCode,
							error.networkResponse.toString());
				} else if (error instanceof TimeoutError) {
					mL.onError(6001, error.toString());
				} else if (error instanceof ServerError) {
					mL.onError(6002, error.toString());
				}
			}
		} catch (Exception e) {
			mL.onError(404,"null");
		}

	}
};
